All Questions
Tagged with programming-practicesdesign-patterns
123 questions
-2votes
1answer
163views
Best Practices for Managing Multiple Entity Types in ASP.NET Core
I'm working on an ASP.NET Core application that requires handling multiple types of a single entity. Each type has its own properties and validation rules, which has led to confusion and complexity in ...
0votes
4answers
199views
How to eliminate repetition in three subclasses: each defines an identical method that does almost the same thing, but with a different return type
TLDR: I have three subclasses, each inherits from the same parent class, each defines an identical method that does almost the same thing, except that each of these methods has a different return type....
0votes
1answer
367views
How best to share common steps between services while allowing them to provide their own behaviour
I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult: public IResult FooService(Foo foo) { ... } public ...
-1votes
1answer
107views
How can I prevent an object from being re-sanitized everytime it is passed as input to a function?
Suppose that I have a class named CharStream Additionally, there are a large number of functions which convert their function input into a CharStream def funky_the_function(_input): input = ...
4votes
2answers
1kviews
How to organize a chain of functions that share parameters, functional programming
When trying to follow a functional programming paradigm, I often find myself in a situation where I have a chain of functions that I would want to combine/compose somehow, but they all also take in a ...
0votes
2answers
932views
Best pattern/practice to execute a multi-step code generation process
I am working on a project that generates an API with the possibility of doing CRUD operations based on a high-level description of the resources that the user would like to have in an application. In ...
2votes
2answers
584views
Design of a modular application
I'm developing an application (Java) in a modular architecture. I have two approaches in mind and I'm not sure which one will be "better code" in case of maintenance and conventions. I have ...
1vote
1answer
398views
Common methods of generating code with code
I wish to develop an application that can generate code based on an user input. Long story short: a user gives a formal description of a Resource (can be viewed as a REST resource) and based on this ...
3votes
4answers
780views
Is it a bad practice to have an interface method to tell whether it can handle an object?
interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
0votes
1answer
671views
Source of "... against the interface, not the implementation"
For a paper I am writing, I need to find the origin of the following two phrases: Code against the interface, not the implementation and Test the interface, not the implementation (Note: the ...
1vote
1answer
821views
Is it bad practice to run different versions of code in different environments? (i.e. test, prod)
As an example, let's say you have the following pseudocode: if test environment: # meaning you don't have the typical service account prod perms sudo as service account + do operation else: # in ...
3votes
2answers
207views
Checking the user in almost all use cases
I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
4votes
3answers
1kviews
Passing object or using the field
I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
0votes
2answers
555views
MVC who knows about whom?
In the Model-View-Controller pattern, I do understand the role of each component. The Model represents our application's domain model. The View presents this information and the controller ...
-2votes
1answer
504views
What are the best practices for writing a long, multi-step process? [closed]
When writing a long process, i.e. one filled with many steps of business logic, what are the best practices for organising it? There are a few different options here that I can see: Just write a long ...